package com.vue.designPatterns.factory;

/**
 * Created by Administrator on 2019/3/14.
 * 工厂方法模式
 */
public class SendFactory {

    public Sender product(String type) {
        if (type.equals("mail")) {
            return new MailSender();
        } else if (type.equals("sms")) {
            return new SmsSender();
        } else {
            System.out.println("请输入争取的类型");
            return null;
        }
    }

    //静态工厂方法
    public static Sender produceMail() {
        return new MailSender();
    }

    public static Sender produceSms() {
        return new SmsSender();
    }
}
